clear

use "SL_afrobarometer_2022.dta"

*partisanship
gen closetoparty=.
replace closetoparty=1 if Q89A==1
replace closetoparty=0 if Q89A==0
sum closetoparty

gen slpp=0
replace slpp=1 if Q89B==930

gen apc=0
replace apc=1 if Q89B==931

gen otherparty=1
replace otherparty=0 if (apc==1 |slpp==1)
replace otherparty=0 if Q89B==-1 | Q89B==9997 | Q89B==9998 | Q89B==9999

sum slpp apc otherparty

*ethnic groups
generate krio=0
replace krio=1 if Q84A==930

generate mende=0
replace mende=1 if Q84A==931

generate themne=0
replace themne=1 if Q84A==932

generate kono=0
replace kono=1 if Q84A==933

generate loko=0
replace loko=1 if Q84A==934

generate sherbro=0
replace sherbro=1 if Q84A==935

generate limba=0
replace limba=1 if Q84A==936

generate fullah=0
replace fullah=1 if Q84A==937

generate koranko=0
replace koranko=1 if Q84A==938

generate yalunka=0
replace yalunka=1 if Q84A==939

generate madingo=0
replace madingo=1 if Q84A==940

generate susu=0
replace susu=1 if Q84A==941

generate vai=0
replace vai=1 if Q84A==942

generate kru=0
replace kru=1 if Q84A==943

generate gola=0
replace gola=1 if Q84A==944

generate kissi=0
replace kissi=1 if Q84A==945

*region
gen eastern=0
replace eastern=1 if REGION==930

gen northern=0
replace northern=1 if REGION==931 

gen southern=0
replace southern=1 if REGION==932

gen western=0
replace western=1 if REGION==933

gen northwestern=0
replace northwestern=1 if REGION==934

*urban
gen urban=.
replace urban=1 if URBRUR==1
replace urban=0 if URBRUR==2


** Table D1 (Appendix D): Correlations between Partisanship and Ethnicity/Region in the SL 2023 Afrobarometer, All Respondents **
reg slpp mende themne limba kono eastern southern northern northwestern krio loko sherbro fullah koranko yalunka madingo susu vai kru gola kissi 
reg apc mende themne limba kono eastern southern northern northwestern krio loko sherbro fullah koranko yalunka madingo susu vai kru gola kissi 
reg otherparty mende themne limba kono eastern southern northern northwestern krio loko sherbro fullah koranko yalunka madingo susu vai kru gola kissi 


** Correlations between Partisanship and Ethnicity/Region in the SL 2023 Afrobarometer, Urban Respondents Only (not in the appendix as a table but referenced in text of Appendix D) **
reg slpp mende themne limba kono eastern southern northern northwestern krio loko sherbro fullah koranko yalunka madingo susu vai kru gola kissi if urban==1
reg apc mende themne limba kono eastern southern northern northwestern krio loko sherbro fullah koranko yalunka madingo susu vai kru gola kissi if urban==1
reg otherparty mende themne limba kono eastern southern northern northwestern krio loko sherbro fullah koranko yalunka madingo susu vai kru gola kissi if urban==1
